/**
 * 
 */
package kr.co.insoft.driver.amazon.model;

import java.util.HashSet;
import java.util.Set;

import kr.co.insoft.driver.model.InstanceModel;

import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.Tag;

/**
 * @author IN-SOFT Inc. GoodwillDD(sylee@in-soft.co.kr)
 * 
 */
public class AmazonInstanceModel extends InstanceModel {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4350012778569601397L;

	/**
	 * @param instance
	 */
	public AmazonInstanceModel(Instance instance) {
		setArchitecture(instance.getArchitecture());
		setHypervisor(instance.getHypervisor());
		setImageId(instance.getImageId());
		setInstanceId(instance.getInstanceId());
		setInstanceType(instance.getInstanceType());
		setKernelId(instance.getKernelId());
		setKeyName(instance.getKeyName());
		setLaunchTime(instance.getLaunchTime());
		setPlatform(instance.getPlatform());
		setPrivateDnsName(instance.getPrivateDnsName());
		Set<String> privateIp = new HashSet<String>();
		privateIp.add(instance.getPrivateIpAddress());
		setPrivateIpAddress(privateIp);
		setPublicDnsName(instance.getPublicDnsName());
		Set<String> publicIp = new HashSet<String>();
		publicIp.add(instance.getPublicIpAddress());
		setPublicIpAddress(publicIp);
		setRamdiskId(instance.getRamdiskId());
		setCurrentState(instance.getState().getName());
		for(Tag tag : instance.getTags()) {
			if ( tag.getKey().equals("Name") ) {
				setInstanceName(tag.getValue());
				break;
			}
		}
	}
}
